﻿import com.gamepackage.events.Executable;

class com.gamepackage.events.Impuls
{
	static private var exes: Array;

	static function initialize( timeline: MovieClip ): Void
	{
		exes = new Array;

		timeline.onEnterFrame = fire;
	}

	static function connect( exe: Executable ): Void
	{
		exes.push( exe );
	}

	static function disconnect( exe: Executable ): Boolean
	{
		var e: Number = exes.length;
		while( --e > -1 )
		{
			if ( exes[e] == exe )
			{
				exes.splice( e , 1 );
				return true;
			}
		}
		return false;
	}

	static function fire(): Void
	{
		var e: Number = exes.length;
		while( --e > -1 )
		{
			exes[e].execute();
		}
	}
}